package com.flyco.modules.task.xml;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@XStreamAlias("ItResult")
@Data
public class SapDistributorBalanceRespXML {
    @XStreamImplicit(itemFieldName = "item")
    private List<DistributorBalanceItem> itemList = new ArrayList<>();

    public DistributorBalanceItem getItemByType(String type) {
        return itemList.stream().filter(q -> Objects.equals(q.getZctyp(), type)).findFirst().orElse(null);
    }

    @Data
    @XStreamAlias("item")
    public class DistributorBalanceItem {

        @XStreamAlias("Zindex")
        private String Zindex;

        @XStreamAlias("Kunnr")
        private String Kunnr;

        @XStreamAlias("Bukrs")
        private String Bukrs;

        @XStreamAlias("Gjahr")
        private String Gjahr;

        @XStreamAlias("Zmonth")
        private String Zmonth;

        @XStreamAlias("Soldtxt")
        private String Soldtxt;

        @XStreamAlias("Zctyp")
        private String Zctyp;

        /**
         *
         */
        @XStreamAlias("Budat")
        private String Budat;

        /**
         *
         */
        @XStreamAlias("Sgtxt")
        private String Sgtxt;

        /**
         * 余额
         */
        @XStreamAlias("Zjine1")
        private BigDecimal Zjine1;

        /**
         * 销售额
         */
        @XStreamAlias("Zjine2s")
        private BigDecimal Zjine2s;

        /**
         * 收款
         */
        @XStreamAlias("Zjine2h")
        private BigDecimal Zjine2h;
    }
}

